// my_spk/pages/address_list/index.js
const app = getApp()
Page({
  data: {
    addressList: [],
    activeId: ''
  },
  onShow() {
    this.setData({ addressList: app.address })
  },
  goAddressAdd() {
    wx.navigateTo({
      url: '/my_spk/pages/address_add/index',
    })
  },
  delAddress({ mark: { id } }) {
    this.setData({ activeId: id })
    wx.showModal({
      title: '提示',
      content: '确定要删除该地址信息吗？',
      success: (res) => {
        if (res.confirm) {
          app.address = app.address.filter(item => item.id !== id)
          this.setData({ addressList: app.address })
          wx.setStorageSync('address', JSON.stringify(app.address))
          wx.utils.toast('信息已删除', 'success')
        }
        this.setData({
          activeId: ''
        })
      }
    })

  }

})